package com.ruoyi.business.service.impl;

import com.ruoyi.business.domain.TBusinessApplication;
import com.ruoyi.business.service.TBusinessApplicationService;
import com.ruoyi.business.mapper.TBusinessApplicationMapper;
import com.ruoyi.common.constant.BusinessAppContants;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 80558
* @description 针对表【t_business_application】的数据库操作Service实现
* @createDate 2024-11-13 09:14:30
*/
@Service
public class TBusinessApplicationServiceImpl implements TBusinessApplicationService{
    @Autowired
    private TBusinessApplicationMapper tBusinessApplicationMapper;

    @Override
    public AjaxResult submitAppForm(TBusinessApplication tBusinessApplication) {
        tBusinessApplication.setState(BusinessAppContants.AUDIT);
        int row = tBusinessApplicationMapper.addApplication(tBusinessApplication);
        if(row>0){
            return AjaxResult.success("提交成功！");
        }
        return AjaxResult.error("提交失败！");
    }

    @Override
    public AjaxResult getAppData(int userId) {
        List<TBusinessApplication> tBusinessApplications= tBusinessApplicationMapper.queryAppStateByUserId(userId);
        if(tBusinessApplications.size()>0){
            return AjaxResult.success(tBusinessApplications.get(0));
        }
        return AjaxResult.error(-1,"没有数据");
    }
}




